﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Imaging;

namespace BeerManagementSystem
{
    public class UserProfile
    {
        private User _user;
        private BitmapImage _userImage;
        private static Dictionary<int, string> UserDegrees;
        private string _currentDegree, _nextDegree;
        private int _currentRank, _currentDegreeValue, _nextDegreeValue;
        
        public UserProfile(User u)
        {
            _user = u;
            _userImage = new BitmapImage();
            UpdateDegree(u);
            InitializeUserDegrees();
        }

        public User User
        {
            get { return _user; }
        } 

        public BitmapImage BitmapImage
        {
            get { return _userImage; }
            set { _userImage = value; }
        }

        public int CurrentRank
        {
            get { return _currentRank; }
            set { _currentRank = value; }
        }

        public string CurrentDegree
        {
            get { return _currentDegree; }
        }

        public  string NextDegree
        {
            get { return _nextDegree; }
        }

        public int CurrentDegreeValue
        {
            get { return _currentDegreeValue; }
        }

        public int NextDegreeValue
        {
            get { return _nextDegreeValue; }
        }

        private static void InitializeUserDegrees()
        {
            UserDegrees = new Dictionary<int, string>
                {
                    {10, "Vorbier"},
                    {20, "Bierschüler"},
                    {50, "Musterschüler"},
                    {100, "Sekundarstufe I"},
                    {200, "Sekundarstufe II"},
                    {300, "Allgemeine Vollbierreife"},
                    {400, "Bachelor of Cerevisia"},
                    {500, "Master of Cerevisia"},
                    {600, "Doktorand"},
                    {750, "Dr. Dr. hc."},
                    {1000, "Prof. Dr. Dr. hc."},
                    {1500, "Alkoholiker"}
                };
        }

        private void UpdateDegree(User user)
        {
            InitializeUserDegrees();
            foreach (var pairs in UserDegrees)
            {
                _nextDegreeValue = pairs.Key;
                _nextDegree = pairs.Value;
                if (user.Beer_total < pairs.Key) break;
                _currentDegree = _nextDegree;
                _currentDegreeValue = _nextDegreeValue;
            }
        }
    }
}
